//
//  HomeTableViewController.swift
//  SwiftSina
//
//  Created by Jason Ding on 16/1/16.
//  Copyright © 2016年 Jason Ding. All rights reserved.
//

import UIKit
import SVProgressHUD

class HomeViewController: BaseViewController {
    // MARK:- 属性
    
    // MARK:- 懒加载属性
    lazy var titleBtn :TitleButton = TitleButton()
    lazy var popvorAnimator = PopoverAnimator()
    
    
    // MARK:- Left Cycle
    override func viewDidLoad() {
        super.viewDidLoad()
        visitorView.addRotationViewAnim()
        
        guard isLogin else{
            return
        }
        
        setupNavgationBar()
        
    }
}

// MARK:- 设置UI界面
extension HomeViewController {
    private func setupNavgationBar() {
        // 1.左按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(imageName: "navigationbar_friendattention")
        // 2.右按钮
        navigationItem.rightBarButtonItem = UIBarButtonItem(imageName: "navigationbar_pop")

        // 3.titleView
        titleBtn.setTitle("哈哈哈", forState: .Normal)
        titleBtn.addTarget(self, action: #selector(HomeViewController.titleBtnClick(_:)), forControlEvents: .TouchUpInside)
        navigationItem.titleView = titleBtn
        
    }
}
// MARK:- BtnClick
extension HomeViewController{
    
    @objc private func titleBtnClick(titleBtn:TitleButton){
        titleBtn.selected = !titleBtn.selected
        
        let popVC = PopverViewController()
        popVC.modalPresentationStyle = .Custom
        
        // 设置自定义转场
        popVC.transitioningDelegate = popvorAnimator
        
        
        presentViewController(popVC, animated: true) {
            
        }
    }
}
